package org.qingke.mail.backend.service;

import java.util.List;

import org.qingke.mail.common.EUDataGridResult;
import org.qingke.mail.common.Response;
import org.qingke.mail.common.SearchProperty;
import org.qingke.mail.domain.TbItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * 商品查询接口实现类
 * @author Administrator
 *
 */
@Service("itemService")
public class ItemServiceImpl implements ItemService{
    
	@Autowired
	private RestTemplate  restTemplate;
	
	@Override
	public EUDataGridResult list(int page, int rows) {
		SearchProperty searchProperty=new SearchProperty();
		searchProperty.setPageNum(page);
		searchProperty.setPageSize(rows);
		// 请求商品服务接口获取数据
		Response response = restTemplate.postForEntity("http://ITEM-SERVICE/item/list", searchProperty, Response.class).getBody();
		//创建一个返回值对象
		EUDataGridResult result=new EUDataGridResult();
		if (response.isState()) {
			result.setRows((List<TbItem>)response.getData());
			result.setTotal(10);
		}
		return result;
	}

}
